package com.gitee.wsl.mvi

import com.gitee.wsl.struct.event.Event

/** 用户与ui的交互事件*/
interface Action:Event
/** ui响应的状态*/
interface State
/** ui响应的事件*/
interface Effect


/*abstract class EventsHandler<Payloads>(
    val fillPayload: (cache: Payloads) -> Unit
) {
    abstract val payloadCache: Payloads
    private val eventMap = mutableMapOf<KClass<out Action>, Payloads.(event: Action) -> Unit>()

    fun handleEvent(event: Action) {
        eventMap[event::class]?.let { handle ->
            handle.invoke(payloadCache.also { fillPayload(it) }, event)
        }
    }

    operator fun <EventType : Action> set(event: KClass<out EventType>, lambda: Payloads.(event: EventType) -> Unit) {
        eventMap[event] = lambda as Payloads.(event: Action) -> Unit
    }

    *//*infix fun <Payloads, EventType : Action> KClass<out EventType>.to(lambda: Payloads.(event: EventType) -> Unit) {
        eventMap[this] = lambda as (Payloads.(event: Action) -> Unit)
    }*//*

    inline fun <reified EventType : Action> register(noinline lambda: Payloads.(event: EventType) -> Unit) : Any {
        this[EventType::class] = lambda
        return lambda
    }
}*/

